package edu.ynu.se.xiecheng.achitectureclass.entity;

import edu.ynu.se.xiecheng.achitectureclass.common.entity.LogicEntity;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.Where;

import javax.persistence.*;
import java.util.Date;

@Getter
@Setter
@Entity
@Where(clause = "is_deleted = 0")
public class Device extends LogicEntity {

    @Column(name = "name", nullable = false)
    private String name;

    @Column(name = "serial_number", nullable = false, unique = true)
    private String serialNumber;  // 唯一设备序列号

    @Column(name = "category", nullable = false)
    private Integer category;  // 设备分类

    @Column(name = "unit")
    private String unit;  // 单位

    @Column(name = "monitor_address")
    private String monitorAddress;  // 监控地址

    @Column(name = "greenhouse_id", nullable = false)
    private Long greenhouseId;  // 所属大棚ID

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "greenhouse_id", insertable = false, updatable = false)
    private Greenhouse greenhouse;

}